﻿#region Comments
/* Description: This code will read template i.e.HTML file and display data.
 */
#endregion

#region Using
using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.IO;
#endregion

public partial class ReadTemplate : System.Web.UI.Page
{
    #region Control Events
    /// <summary>
    /// Handler for Page_Load event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        string strFileName = "template/Template.htm";
        string strFilePath = HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath.Replace("/", "\\")) + "\\" + strFileName;
        lbl.Text = ReadTemplateFile(strFilePath);
    }
    #endregion

    #region Functions
    /// <summary>
    /// Function to read the template
    /// </summary>
    /// <param name="FilePath">File path</param>
    /// <returns>string of template</returns>
    private string ReadTemplateFile(string FilePath)
    {
        string tempReadTemplate = null;

        tempReadTemplate = "";
        if (File.Exists(FilePath))
        {
            StreamReader objStreamReader = null;
            objStreamReader = File.OpenText(FilePath);
            string contents = objStreamReader.ReadToEnd().ToString();
            objStreamReader.Close();
            tempReadTemplate = contents;
        }
        return tempReadTemplate;
    }
    #endregion
}
